home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d8 / nhost.arc / NEWHOST.SLT < prev    next >
Text File  |  1989-10-08  |  52KB  |  1,442 lines

  1.  
  2. /////////////////////////////////////////////////////////////////////////////
  3. //
  4. //   N E W H O S T . S L T
  5. //
  6. //   Copyright (C) 1988 PTel and Colin Sampaleanu
  7. //
  8. //   This is a Host Mode for Telix, written as a script file.
  9. //   To configure Host Mode parameters such as passwords, run the 'NCONFIG'
  10. //   script. That script is run automatically if the Host Mode configuration
  11. //   file 'NHOST.CNF' is missing.
  12. //
  13. //   This script will only work with Hayes compatible modems, but may be
  14. //   modified for operation with othe rmodems.
  15. //
  16. //////////////////////////////////////////////////////////////////////////////
  17.  
  18. // Revised by Jon Fleming (BIX: jfleming)  11/25/88 to use individual
  19. //     passwords, let anyone with level 3 access get at the shell or shut
  20. //     down host mode.
  21. // *** Modified By Al Cerny for use with BiModem Transfers. ***
  22. //
  23. //////////////////////////////////////////////////////////////////////////////
  24.  
  25. //
  26. // *** Place compiled scripts NEWHOST.slc and NCONFIG.slc in directory with
  27. //     other script files. Place file message.lst in directory with Telix exe.
  28. //     Refer to Telix.doc for further instructions, if needed.
  29.  
  30. //////////////////////////////////////////////////////////////////////////////
  31.  
  32. //  Parameters which can be configered.
  33.  
  34. str s[8],
  35.     address[20],
  36.     citystate[20],
  37.     zipcode[5],
  38.     voicephone[14],
  39.     modemphone[14],
  40.     password[16],
  41.     host_downloads[64],                 // where users may download from
  42.     host_uploads[64];                   // where uploaded files go
  43. int direct_connect = 0;
  44. int f = 0;
  45.  
  46. str current_caller[31],                 // storage of current caller's name
  47.     message[512],
  48.     conn300[] = "CONNECT^M",            // modem result messages for bauds
  49.     conn1200[] = "CONNECT 1200",
  50.     conn2400[] = "CONNECT 2400",
  51.     conn9600[] = "CONNECT 9600",
  52.     conn19200[] = "CONNECT 19200";
  53. int finished_caller,                    // set to TRUE when must return to top
  54.     local_mode,                         // set to TRUE when local test mode
  55.     access_level,                       // access level of current caller
  56.     we_care_about_carrier = 1,                 // TRUE if should watch Carrier signal
  57.     already_connected = 0,
  58.     exit_requested = 0,                 // set to TRUE if Sysop has pressed Esc
  59.     connection_lost = 0,                // set to TRUE when carrier lost
  60.     kill_user = 0,                      // set to TRUE when user must be purged
  61.     min_user_name = 5;                      // Minimum length of a user name
  62.  
  63. int old_scr_chk_key,                    // storage for some system variables
  64.     old_cisb_auto,                      // which we have to modify and put
  65.     old_zmod_auto,                      // back to what they were when done
  66.     old_sound;
  67. str old_down_dir[64],
  68.     old_up_dir[64];
  69.  
  70. //////////////////////////////////////////////////////////////////////////////
  71. //////////////////////////////////////////////////////////////////////////////
  72.  
  73. main() {
  74.  
  75.    int c;
  76.  
  77.    clear_scr();
  78.  
  79.    if (read_host_config_file() == -1) {
  80.        prints("Unable to read NHOST.CNF...");
  81.        prints("Running NCONFIG, the Host Mode configuration script.^M^J");
  82.        call("NCONFIG");
  83.        if (read_host_config_file() == -1) {
  84.            prints("Still unable to read NHOST.CNF. Aborting Host Mode.^M^J");
  85.            return -1;
  86.        }
  87.    }
  88.  
  89.    if (!check_directories()) {
  90.        prints("Either the upload or download directory as defined in the NHOST.CNF file");
  91.        prints("doesn't exist. Either create the missing directory with the DOS 'MKDIR'");
  92.        prints("command, or run the NCONFIG script to redefine what directories to use.");
  93.        prints("Aborting Host Mode.");
  94.        return -1;
  95.    }
  96.  
  97.    old_scr_chk_key = _scr_chk_key;
  98.    _scr_chk_key = 0;
  99.    old_cisb_auto = _cisb_auto;
  100.    _cisb_auto = 0;
  101.    old_zmod_auto = _zmod_auto;
  102.    _zmod_auto = 0;
  103.    old_sound = _sound_on;
  104.    _sound_on = 0;
  105.    old_down_dir = _down_dir;
  106.    _down_dir = host_uploads;   // these are reversed because we are now the Host
  107.    old_up_dir = _up_dir;
  108.    _up_dir = host_downloads;   // these are reversed because we are now the Host
  109.  
  110.    usagelog("HOST.LOG");
  111.  
  112.    if (direct_connect)
  113.        we_care_about_carrier = 0;
  114.    else
  115.        we_care_about_carrier = 1;
  116.  
  117.    if (!direct_connect && carrier())
  118.        already_connected = 1;
  119.  
  120.    if (!direct_connect && !already_connected) {
  121.        prints("Initializing modem");
  122.        prints("To auto answer^M^J");
  123.        delay(15);
  124.        cputs_tr(_auto_ans_str);
  125.  
  126.    }
  127.  
  128.    while (1) {
  129.        finished_caller = kill_user = 0;
  130.  
  131.        if (direct_connect)
  132.            we_care_about_carrier = 0;
  133.        else
  134.            we_care_about_carrier = 1;
  135.  
  136.        if (!direct_connect) {
  137.        prints("^L^M^J");
  138.        prints("^M^J");
  139.        prints("^M^J");
  140.        prints("                    ┌────────────┐");
  141.        prints("                 ╒══╡ TELIX Host ╞════════════════════════════╕");
  142.        prints("                 │  └────────────┘                            │");
  143.        prints("                 │    STATUS: Waiting for call...             │");
  144.        prints("                 │ ────────────────────────────────────────── │");
  145.        prints("                 │   OPTIONS: Press ESC, to return to Telix   │");
  146.        prints("                 │            Press `L' to log on locally     │");
  147.        prints("                 │                                            │");
  148.        prints("                 ╘════════════════════════════════════════════╛^M^J");
  149.        gotoxy(57,12);
  150.  
  151.            do {
  152.                if (carrier()) {
  153.                    local_mode = 0;
  154.                    break;
  155.                }
  156.  
  157.                c = inkey();
  158.                if (c) {
  159.                    if (c == 27) {
  160.                        exit_requested = 1;
  161.                        break;
  162.                    }
  163.                    else if (c == 'l' || c == 'L') {            // local test mode
  164.                        local_mode = 1;
  165.                        we_care_about_carrier = 0;
  166.                    }
  167.                }
  168.            }
  169.            while (toupper(c) != 'L');
  170.        }
  171.  
  172.        if (!exit_requested) {
  173.            host_send("^LTELIX HOST v2.0    ========================     Script file for Telix 3.xx^G^M^J^M^J");
  174.            prints(" SysOp: Press F1 to Chat with user.");
  175.            prints("        Press F2 to Edit messagese.");
  176.            prints("        Press F3 to use DOS functions.");
  177.            prints("        Press F4 to Hang-Up on undesireable user.");
  178.            prints("        Press F5 to end session & return to Telix.");
  179.            _sound_on=1;
  180.            tone(500, 10);
  181.            tone(900, 10);
  182.            tone(500, 10);
  183.            tone(900, 10);
  184.            tone(500, 10);
  185.            tone(900, 10);
  186.            tone(500, 10);
  187.            tone(900, 10);
  188.            tone(500, 10);
  189.            tone(900, 10);
  190.            tone(500, 10);
  191.            tone(900, 10);
  192.            tone(500, 10);
  193.            tone(900, 10);
  194.            tone(500, 10);
  195.            tone(900, 10);
  196.            tone(500, 10);
  197.            tone(900, 10);
  198.            tone(500, 10);
  199.            tone(900, 10);
  200.            tone(500, 10);
  201.            delay(25);
  202.            do_one_caller();
  203.            if ((connection_lost || kill_user) && we_care_about_carrier && carrier())
  204.                hangup();             // make sure nobody sneaks in
  205.        }
  206.        already_connected = 0;
  207.        if (exit_requested) {
  208.            if (!carrier() && !direct_connect)
  209.                cputs_tr(_mdm_init_str);
  210.            _scr_chk_key = old_scr_chk_key;
  211.            _cisb_auto = old_cisb_auto;
  212.            _zmod_auto = old_zmod_auto;
  213.            _sound_on = old_sound;
  214.            _down_dir = old_down_dir;
  215.            _up_dir = old_up_dir;
  216.            prints("^M^JHost mode script finished.");
  217.            usagelog("*CLOSE*");
  218.            return 1;
  219.        }
  220.    }
  221. }
  222. //////////////////////////////////////////////////////////////////////////////
  223.  
  224. do_one_caller() {
  225.  
  226.    str strn[80], fname[64], temporary[1];
  227.  
  228.    int option, status, c, i, i2;
  229.  
  230.    access_level = 1;
  231.  
  232.    if (already_connected)
  233.        prints("Already Connected!");
  234.    else if (we_care_about_carrier) {
  235.        if (!determine_baud())
  236.            ;                       // do something else here if this is a problem
  237.    }
  238.  
  239.    delay(10);
  240.    type_file("LOGO.MSG");
  241.  
  242.    flushbuf();
  243.    while (1) {
  244.  
  245.            host_send("^M^J");
  246.            host_send("^M^J");
  247.            host_send("^M^J");
  248.            host_send("^M^J");
  249.            host_send("^M^J");
  250.        host_send("Please enter your full name: ");
  251.        host_input_strn(current_caller, 30, 0);
  252.        host_send("^M^J");
  253.  
  254.        if (finished_caller)
  255.            return;
  256.  
  257.        if (strlen(current_caller) >= min_user_name) {
  258.            host_send ("^"");
  259.            host_send (current_caller);
  260.            host_send ("^", correct? (y/N): ");
  261.            host_input_strn (temporary, 30, 0);
  262.            host_send ("^M^J");
  263.  
  264.            if (strcmpi (temporary, "y") == 0)
  265.                break;
  266.        }
  267.        else
  268.            host_send ("Name too short!^M^J");
  269.    }
  270.  
  271.    if (access_level = ask_for_pass(3)) {
  272.        ustamp("Logon by: ", 1, 0);
  273.        ustamp(current_caller, 0, 1);
  274.    }
  275.    else {
  276.        host_send("Goodbye and call again soon!^M^J");
  277.        if (we_care_about_carrier) {
  278.            delay(10);
  279.            hangup();
  280.    }
  281.        ustamp("Failed logon attempt by ", 1, 0);
  282.        ustamp(current_caller, 0, 1);
  283.        return;
  284.    }
  285.  
  286.  
  287.    while (1) {
  288.        if (finished_caller)
  289.            return;
  290.  
  291.        if (access_level <= 2) {
  292.  
  293.            host_send("                        ╒═══════════════╤═══════════════╕^M^J");
  294.            host_send("                        │[F]Ile listings│[C]hat request │^M^J");
  295.            host_send("                        ├───────────────┼───────────────┤^M^J");
  296.            host_send("                        │[T]ype txt.file│[G]oodby-logoff│^M^J");
  297.            host_send("                        ├───────────────┼───────────────┤^M^J");
  298.            host_send("                        │[L]eave Message│   not in use  │^M^J");
  299.            host_send("                        ├───────────────┼───────────────┤^M^J");
  300.            host_send("                        │[U]pload  file │   not in use  │^M^J");
  301.            host_send("                        ├───────────────┼───────────────┤^M^J");
  302.            host_send("                        │[D]ownload file│   not in use  │^M^J");
  303.            host_send("                        ├───────────────┼───────────────┤^M^J");
  304.            host_send("                        │[B]iModem-trsf.│   not in use  │^M^J");
  305.            host_send("                        ├───────────────┼───────────────┤^M^J");
  306.            host_send("                        │[R]ead Bu]liten│   not in use  │^M^J");
  307.            host_send("                        ╘═══════════════╧═══════════════╛^M^J");
  308.            host_send("^M^J");
  309.               prints("            ╒═╡ SysOp OPTIONS ╞══════════════════════════════════════╕");
  310.               prints("            │ F1 - To chat with user          F2 - To edit bulletins │");
  311.               prints("            │ F3 - To use DOS functions       F4 - Terminate User    │");
  312.               prints("            │ F5 - To return to Telix         F6 - Norton Commander  │");
  313.               prints("            │────────────────────────────────────────────────────────│");
  314.               prints("            │ Online:^"                         Todays Date:          │");
  315.               prints("            ╘════════════════════════════════════════════════════════╛");
  316.              gotoxy(22,21);
  317.              printsc(current_caller);
  318.              printsc("^"");
  319.              gotoxy(60,21);
  320.              date(curtime(), s);
  321.              printsc(s);
  322.              host_send("^M^J");
  323.              host_send("^M^JSelect... > "); }
  324.  
  325.        else {
  326.  
  327.            host_send("                        ╒═══════════════╤═══════════════╕^M^J");
  328.            host_send("                        │[F]Ile listings│[C]hat request │^M^J");
  329.            host_send("                        ├───────────────┼───────────────┤^M^J");
  330.            host_send("                        │[T]ype txt.file│[G]oodby-logoff│^M^J");
  331.            host_send("                        ├───────────────┼───────────────┤^M^J");
  332.            host_send("                        │[L]eave Message│[S]hell to DOS │^M^J");
  333.            host_send("                        ├───────────────┼───────────────┤^M^J");
  334.            host_send("                        │[U]pload  file │ctrl-z Shut dn.│^M^J");
  335.            host_send("                        ├───────────────┼───────────────┤^M^J");
  336.            host_send("                        │[D]ownload file│[*] view - log │^M^J");
  337.            host_send("                        ├───────────────┼───────────────┤^M^J");
  338.            host_send("                        │[B]iModem-trsf.│[R]ead Bulliten│^M^J");
  339.            host_send("                        ├───────────────┼───────────────┤^M^J");
  340.            host_send("                        │Read [M]essages│User [H]istory │^M^J");
  341.            host_send("                        ╘═══════════════╧═══════════════╛^M^J");
  342.            host_send("^M^J");
  343.               prints("            ╒═╡ SysOp OPTIONS ╞══════════════════════════════════════╕");
  344.               prints("            │ F1 - To chat with user          F2 - To edit bulletins │");
  345.               prints("            │ F3 - To use DOS functions       F4 - Terminate User    │");
  346.               prints("            │ F5 - To return to Telix         F6 - Norton Commander  │");
  347.               prints("            │────────────────────────────────────────────────────────│");
  348.               prints("            │ Online:^"                         Todays Date:          │");
  349.               prints("            ╘════════════════════════════════════════════════════════╛");
  350.              gotoxy(22,21);
  351.              printsc(current_caller);
  352.              printsc("^"");
  353.              gotoxy(60,21);
  354.              date(curtime(), s);
  355.              printsc(s);
  356.              host_send("^M^J");
  357.              host_send("^M^JSelect... > ");  }
  358.  
  359.        host_input_strn(strn, 1, 0);
  360.        option = toupper(subchr(strn, 0));
  361.        host_send("^M^J");
  362.  
  363.        if (option == 'F') {                 // Files directory
  364.            if (access_level >= 2) {
  365.                host_send("Enter filespec or press <Return> for all. > ");
  366.                host_input_strn(fname, 64, 0);
  367.                host_send("^M^J");
  368.  
  369.                if (just_filename(fname)) {
  370.                    strn = host_downloads;
  371.                    strcat(strn, fname);
  372.                }
  373.                else
  374.                strn = fname;
  375.            }
  376.            else {
  377.                strn = host_downloads;
  378.                strcat(strn, "*.*");
  379.            }
  380.        
  381.            if (local_mode)
  382.                show_directory(strn, 0, we_care_about_carrier);
  383.            else
  384.                show_directory(strn, 1, we_care_about_carrier);
  385.  
  386.        host_send("^M^J");
  387.         }
  388.  
  389.        else if (option == 'R') {
  390.            type_file("MESSAGE.LST");
  391.            host_send("[More]");
  392.            host_input(strn, 64,0);
  393.            ustamp("User read bulletins.", 1, 1);
  394.         }
  395.        else if (option == 'M')  {
  396.            if (access_level == 3) {
  397.            type_file("MESSAGE.BSE");
  398.            host_send("[More]");
  399.            host_input(strn, 64,0);
  400.            ustamp("User read messages.", 1, 1);
  401.         }
  402.         else  {
  403.            host_send("Not a function, make another selection.^M^J");
  404.            delay(10);
  405.            ustamp("Read message file request denied.", 1, 1); }
  406.         }
  407.         else if (option == 'H')  {
  408.             if (access_level == 3) {
  409.             type_file("USER.INF");
  410.             host_send("[More]");
  411.             host_input(strn, 64,0);
  412.            ustamp("SysOp read user history file.", 1, 1);
  413.         }
  414.         else  {
  415.            host_send("Not a function, make another selection.^M^J");
  416.            delay(10);
  417.            ustamp("Read user history file denied user.", 1, 1); }
  418.         }
  419.        else if (option == '*')  {
  420.            if (access_level == 3) {
  421.            type_file("HOST.LOG");
  422.            host_send("[MORE]");
  423.            host_input(strn, 64,0);
  424.            ustamp("User read host log.", 1, 1);
  425.         }
  426.         else {
  427.            host_send("Not a function, make another selection.^M^J");
  428.            delay(10);
  429.            ustamp("Read host log file denied.", 1, 1); }
  430.         }
  431.  
  432.        else if (option == 'T') {           // Type a file
  433.            host_send("Type what file? ");
  434.            host_input_strn(strn, 64, 0);
  435.            host_send("^M^J");
  436.            if (access_level == 1)             // if access 1, name and ext only
  437.                fnstrip(strn, 3, fname);
  438.            else
  439.                fname = strn;
  440.  
  441.            if (just_filename(fname)) {
  442.                strn = host_downloads;
  443.                strcat(strn, fname);
  444.                fname = strn;
  445.            }
  446.  
  447.            if (!filefind(fname, 0, strn)) {
  448.                host_send("Unable to find ");
  449.                host_send(fname);
  450.                continue;
  451.            }
  452.  
  453.            type_file(fname);
  454.        }
  455.  
  456.        else if (option == 'L')
  457.        {
  458.  
  459.        host_send("^M^J");
  460.        host_send("╔════════════════════════════════════════════════════════════════════════╗^M^J");
  461.        host_send("║ ****  Please do not press <ENTER> until done with entire message! **** ║^M^J");
  462.        host_send("║ There are currently only 6 lines available............                 ║^M^J");
  463.        host_send("╔═╗ Begin below:                                                         ║^M^J");
  464.        host_send(" ╚══════════════════════════════════════════════════════════════════════╝^M^J");
  465.        host_send("^M^J");
  466.        host_send("^M^J");
  467.        host_send("^M^J");
  468.        host_send("^M^J");
  469.        host_send("^M^J");
  470.        host_send("^M^J");
  471.        host_send("^M^J");
  472.        host_send("^M^J");
  473.        host_send("^M^J");
  474.        host_send("^M^J");
  475.        host_send("^M^J");
  476.        host_send("^M^J");
  477.        host_send("^M^J");
  478.        host_send("^M^J");
  479.        host_send("^M^J");
  480.        host_send("^M^J");
  481.        host_send("^M^J");
  482.        host_send("^M^J");
  483.           gotoxy(0,5);
  484.  
  485.           host_input_strn(message, 512, 0);
  486.           f = fopen("MESSAGE.BSE", "a");
  487.            fputs("^M^J", f);
  488.            fputs("Date: ", f);
  489.            date(curtime(), s);
  490.            fputs(s, f);
  491.            fputs("^M^J", f);
  492.            fputs("MESSAGE FROM: ", f);
  493.            fputs(current_caller, f);
  494.            fputs("^M^J", f);
  495.            fputs(message, f);
  496.            fputs("^M^J", f);
  497.            fclose(f);
  498.            host_send("^M^J");
  499.            host_send("Message Saved.....^M^J");
  500.            ustamp("User left message.", 1, 1);
  501.  
  502.        }
  503.  
  504.        else if (option == 'G') {           // Goodbye (Hang-up)
  505.            host_send("^M^J");
  506.            host_send("^M^J");
  507.            host_send("        ╦════╗   ╦     ╦   ╦════╗   ╒═╕^M^J");
  508.            host_send("        ║    ║   ║     ║   ║        │ │^M^J");
  509.            host_send("        ║ ═══╣   ╚══╦══╝   ╠════╣   ╘═╛^M^J");
  510.            host_send("        ║    ║      ║      ║        ┌─┐^M^J");
  511.            host_send("        ╩════╝      ╩      ╩════╝   └─┘^M^J");
  512.            host_send("^M^J");
  513.            host_send("        Thanks for calling!^M^J");
  514.            host_send("^M^J");
  515.            host_send("            Please hang up now.... call again ya hear!!^M^J");
  516.  
  517.            ustamp("User logged off.", 1, 1);
  518.            if (we_care_about_carrier) {
  519.                hangup();
  520.            }
  521.            return;
  522.        }
  523.  
  524.        else if (option == 'C') {           // Chat mode
  525.            host_send("^M^J");
  526.            host_send("Paging the SysOp, hang on a second!^M^J");
  527.            host_send("^M^J");
  528.            prints("^M^J");
  529.            prints("^M^J");
  530.            prints("^M^J");
  531.            prints("            ╔═══╡ User would like to chat with you. ╞═════════════════╗");
  532.            prints("            ║                                                         ║");
  533.            prints("            ║   OPTIONS:  Press space bar to chat with user,          ║");
  534.            prints("            ║             or any other key to say your unavailable.   ║");
  535.            prints("            ║                                                         ║");
  536.            prints("            ╚═════════════════════════════════════════════════════════╝^M^J");
  537.            prints("^M^J");
  538.            prints("^M^J");
  539.            prints("^M^J");
  540.            prints("^M^J");
  541.            c = 0;
  542.            _sound_on = 1;
  543.            for (i = 8; i && !c; --i) {
  544.                if (we_care_about_carrier && !carrier()) {
  545.                    prints("^M^JConnection has been lost, call terminated.^M^J");
  546.                    connection_lost = 1;
  547.                    finished_caller = 1;
  548.                    break;
  549.                }
  550.                cputc('^G');
  551.                tone(523, 20);
  552.                tone(659, 20);
  553.                tone(523, 20);
  554.                tone(659, 20);
  555.                tone(523, 20);
  556.                tone(659, 20);
  557.                for (i2 = 30; i2 && (c = inkey()) == 0; --i2)
  558.                    delay(1);
  559.            }
  560.            _sound_on = 0;
  561.            if (finished_caller)
  562.                continue;
  563.            if (c != ' ' || !c) {
  564.                host_send("Sorry, The Sysop is unavailable^M^J");
  565.                delay(15);
  566.                ustamp("Users chat request denied.", 1, 1);
  567.                continue;
  568.            }
  569.            host_send("The Sysop is here!^M^J");
  570.            chatmode(1);
  571.        }
  572.  
  573.       
  574.        else if (option == 'B') {   //BiModem Transfer
  575.            host_send("^M^JYou have selected BiModem, A DUAL Transfer method.^M^J");
  576.            host_send("Set-Up YOUR end NOW...I am READY for the transfer.  When^M^J");
  577.            host_send("your end prompts to start my end; Type a B and ENTER...^M^J");
  578.            host_input_strn(strn, 1, 0);
  579.            dos("bimodem /R",0);
  580.            clear_scr();
  581.            dos("del BiModem.Pth");
  582.            }
  583.  
  584.        else if (option == 'U') {           // User upload
  585.            if (! (option = host_get_prot()))
  586.                continue;
  587.  
  588.            status = 1;
  589.            if (option == 'T' || option == 'M' || option == 'S' ||
  590.                    option == 'Y' || option == 'Z' || option == 'E') {
  591.                send_transfer_msg();
  592.                status = receive(option, "");
  593.            }
  594.            else {
  595.                host_send("Upload what file? ");
  596.                host_input_strn(strn, 48, 0);
  597.                host_send("^M^J");
  598.                if (!strn)
  599.                    continue;
  600.                if (access_level == 1)             // if access 1, name and ext only
  601.                    fnstrip(strn, 3, fname);
  602.                else
  603.                    fname = strn;
  604.  
  605.                if (just_filename(fname)) {
  606.                    strn = host_uploads;
  607.                    strcat(strn, fname);
  608.                    fname = strn;
  609.                }
  610.  
  611.                if (filefind(fname, 23, strn))
  612.                    host_send("File already exists!^M^J");
  613.                else {
  614.                    send_transfer_msg();
  615.                    status = receive(option, fname);
  616.                }
  617.            }
  618.            if (status == -2)                        // Carrier lost
  619.                connection_lost = finished_caller = 1;
  620.            else if (status == -1)
  621.                host_send("^GOne or more files not received!^M^J");
  622.        }
  623.  
  624.        else if (option == 'D') {           // User download
  625.            if (! (option = host_get_prot()))
  626.                continue;
  627.            host_send("Download what file(s)? ");
  628.            host_input_strn(strn, 48, 0);
  629.            host_send("^M^J");
  630.            if (!strn)
  631.                continue;
  632.            if (access_level == 1)      // if level 1, keep only name & ext
  633.                fnstrip(strn, 3, fname);
  634.            else
  635.                fname = strn;
  636.  
  637.            if (just_filename(fname)) {
  638.                strn = host_downloads;
  639.                strcat(strn, fname);
  640.                fname = strn;
  641.            }
  642.  
  643.            if (!filefind(fname, 0, strn)) {
  644.                host_send("Unable to find any matching file(s)!^M^J");
  645.                continue;
  646.            }
  647.  
  648.            status = 1;
  649.            send_transfer_msg();
  650.            status = send(option, fname);
  651.            if (status == -2)                        // Carrier lost
  652.                connection_lost = finished_caller = 1;
  653.            else if (status == -1)
  654.                host_send("^GOne or more files not received!^M^J");
  655.        }
  656.  
  657.        else if (option == 'S') {           // Remote shell
  658.          if (get_port() !=1 && get_port() !=2) {
  659.                host_send("Shell not supported due to DOS limits!^M^J");
  660.            continue;
  661.        }
  662.  
  663.            if (access_level == 3) {            // Need access level 3 to shell
  664.                host_send("Type EXIT and then press Return to come back.^M^J");
  665.                if (get_baud() == 300)
  666.                    delay(10);
  667.  
  668.                strn = "COM";
  669.                    setchr (strn, 3, get_port() + '0');
  670.                    if (!local_mode)
  671.                    if (redirect_dos(strn) == -1)    // redirect DOS input and output
  672.                        continue;
  673.  
  674.                dos("", 0);                    // actually call the shell
  675.  
  676.                    if (!local_mode)
  677.                        redirect_dos("");         // very important to put things back to norm
  678.            }
  679.            else {
  680.                host_send ("Not a function, make another selection^M^J");
  681.                delay(10);
  682.                ustamp("User denied <shell option>.", 1, 1);
  683.            }
  684.        }
  685.  
  686.        else if (option == '^Z') {            // Shut down Host Mode
  687.            if (access_level == 3) {
  688.                host_send("Shutting down Host Mode.  Goodbye!^M^J");
  689.                if (we_care_about_carrier)
  690.                    hangup();
  691.                ustamp("User shut down Host Mode.", 1, 1);
  692.                finished_caller = 1;
  693.                exit_requested = 1;
  694.            }
  695.            else {
  696.                host_send ("Not a function, make another selection^M^J");
  697.                delay(10);
  698.                ustamp("User denied <shut down option>.", 1, 1);
  699.            }
  700.        }
  701.    }
  702. }
  703.  
  704. //////////////////////////////////////////////////////////////////////////////
  705.  
  706. host_get_prot() {
  707.  
  708.    str prot[1];
  709.  
  710.    host_send("^M^J");
  711.    host_send("^M^J");
  712.    host_send("^M^J");
  713.    host_send("^M^J");
  714.    host_send("^M^J");
  715.    host_send("^M^J");
  716.    host_send("^M^J");
  717.    host_send("                  ╦══╗ ╦══╗ ╔══╗ ╔═╦═╗ ╔══╗ ╔══╗ ╔══╗ ╦    ╔══╗             ^M^J");
  718.    host_send("                  ╠══╝ ╠═╦╝ ║  ║   ║   ║  ║ ║    ║  ║ ║    ╚══╗             ^M^J");
  719.    host_send("                  ╩    ╩ ╚╝ ╚══╝   ╩   ╚══╝ ╚══╝ ╚══╝ ╚══╝ ╚══╝             ^M^J");
  720.    host_send("        ┌────────────┐                                                   ^M^J");
  721.    host_send("      ╔═╡ TELIX Host ╞╤════════════════╤═══════════════╤════════════════╗^M^J");
  722.    host_send("      ║ └────────────┘│                │               │                ║^M^J");
  723.    host_send("      ║  (X)modem     │   Ymod(E)m-g   │ (G)-1k-Xmodem │   (S)ealink    ║^M^J");
  724.    host_send("      ╟───────────────┼────────────────┼───────────────┼────────────────╢^M^J");
  725.    host_send("      ║  (1)k-Xmodem  │   (M)odem-7    │ (Y)modem      │   (Z)modem     ║^M^J");
  726.    host_send("      ║               │                │               │                ║^M^J");
  727.    host_send("      ╚═══════════════╧════════════════╧═══════════════╧════════════════╝^M^J");
  728.    host_send("^M^J");
  729.    host_send("^M^J");
  730.    host_send("^M^J");
  731.    host_send("^M^J");
  732.    host_send("^M^J");
  733.    host_send("^M^JSelect... > ");
  734.    host_input_strn(prot, 1, 0);
  735.    host_send("^M^J");
  736.  
  737.    if (strposi("MSX1GYEZ", prot, 0) == -1)     // if illegal prot
  738.        prot = "";                                 // return 0
  739.  
  740.    return (toupper(subchr(prot, 0)));
  741.  
  742. }
  743.  
  744. //////////////////////////////////////////////////////////////////////////////
  745.  
  746. send_transfer_msg() {
  747.    
  748.    host_send("^M^J");
  749.    host_send("                   ╒══╡ File Transfer ╞═════════════════════╕^M^J");
  750.    host_send("                   │   Status: Ready to transfer file(s)..  │^M^J");
  751.    host_send("                   │────────────────────────────────────────│^M^J");
  752.    host_send("                   │   Option: Press Ctrl-X at least twice  │^M^J");
  753.    host_send("                   │           to abort file transfer.....  │^M^J");
  754.    host_send("                   ╘════════════════════════════════════════╛^M^J");
  755.    
  756. }
  757.  
  758. //////////////////////////////////////////////////////////////////////////////
  759. // Determine the baud rate once a Carrier Detect Signal has been detected
  760. // Since no characters were read, the 'CONNECT' string should still be
  761. // in the receive buffer.
  762.  
  763. determine_baud() {
  764.  
  765.    int t3, t12, t24, t96, t192;
  766.    int tmark, stat;
  767.    int new_baud = 0;
  768.  
  769.    printsc("Determining baud... ");
  770.  
  771.    track_free(0);                // clear all existing tracks
  772.  
  773.    t3 = track(conn300, 0);       // check for connect strings
  774.    t12 = track(conn1200, 0);
  775.    t24 = track(conn2400, 0);
  776.    t96 = track(conn9600, 0);
  777.    t192 = track(conn19200, 0);
  778.  
  779.    tmark = timer_start(30);      // wait up to 3 seconds for string
  780.                              
  781.    while (!time_up(tmark)) {
  782.        if (!carrier()) {
  783.            track_free(0);            // clear all existing tracks
  784.            return 0;
  785.        }
  786.  
  787.    if (cinp_cnt())
  788.        track_addchr(cgetc());
  789.  
  790.    stat = track_hit(0);
  791.    if (stat == 0)
  792.        continue;
  793.  
  794.    if (stat == t3)
  795.        new_baud = 300;
  796.    else if (stat == t24)
  797.        new_baud = 2400;
  798.    else if (stat == t96)
  799.        new_baud = 9600;
  800.    else if (stat == t192)
  801.        new_baud = 19200;
  802.    else
  803.        new_baud = 1200;
  804.  
  805.    break;                      // have baud rate, get out
  806.    }
  807.  
  808.    if (!new_baud) {               // time-up without CONNECT string
  809.        prints("Failed!");
  810.        track_free(0);              // clear all existing tracks
  811.        return 0;     
  812.    }
  813.  
  814.    printn(new_baud);
  815.    prints("");
  816.    set_cparams(new_baud, get_parity(), get_datab(), get_stopb());
  817.  
  818.    track_free(0);                // clear all existing tracks
  819.    return 1;                     // indicate success
  820.  
  821. }
  822.  
  823. //////////////////////////////////////////////////////////////////////////////
  824.  
  825. type_file(str fname) {
  826.  
  827.    int f, control_z_loc;
  828.    str buf[100];
  829.    int ichar, lines_sent = 0;
  830.  
  831.    if (not (f = fopen(fname, "r")))
  832.        return -1;
  833.  
  834.    host_send("^M^J");
  835.  
  836.    while (1) {
  837.        if (we_care_about_carrier) {
  838.            if (!carrier()) {
  839.                connection_lost = 1;
  840.                finished_caller = 1;
  841.                fclose(f);
  842.                return 0;
  843.            }
  844.        }
  845.  
  846.        if (fgets(buf, 80, f) == -1) {
  847.            fclose(f);
  848.            return 1;
  849.        }
  850.  
  851.        if ((control_z_loc = strpos (buf, "^Z", 0)) >= 0) {
  852.            if (control_z_loc == 0) {
  853.                fclose (f);
  854.                return 1;
  855.            }
  856.            else {
  857.                setchr (buf, control_z_loc, 0);
  858.            }
  859.        }
  860.  
  861.        host_send(buf);
  862.        host_send("^M^J");
  863.        ++lines_sent;
  864.  
  865.        if (lines_sent >= 22) {
  866.            lines_sent = 0;
  867.            host_send("[More]");
  868.            host_input(0);
  869.  
  870.            if (finished_caller) {        // if user inactivity
  871.                fclose(f);
  872.                return 0;
  873.            }
  874.  
  875.            host_send("^H ^H^H ^H^H ^H^H ^H^H ^H^H ^H^H ^H");
  876.        }
  877.  
  878.        while (cinp_cnt()) {
  879.            ichar = cgetc();
  880.            if (ichar == '^C' || ichar == '^K') {
  881.                host_send("^M^J");
  882.                fclose(f);
  883.                return 1;
  884.            }
  885.        }
  886.    }
  887. }
  888.  
  889. //////////////////////////////////////////////////////////////////////////////
  890.  
  891. host_send(str outstr) {
  892.  
  893.    printsc(outstr);
  894.    if (!local_mode)
  895.        cputs(outstr);
  896.  
  897. }
  898.  
  899. //////////////////////////////////////////////////////////////////////////////
  900.  
  901. host_send_c(int chr) {
  902.  
  903.    printc(chr);
  904.    if (!local_mode)
  905.        cputc(chr);
  906.  
  907. }
  908.  
  909. //////////////////////////////////////////////////////////////////////////////
  910.  
  911. host_input_strn(str buf, int maximum, int echo_asterisk) {
  912.  
  913. //Rev 11/25/88 by Jon Fleming to echo a string of asterisks if
  914. //     "echo_asterisk" is non-zero, echo the input string if "echo_asterisk"
  915. //     is zero.
  916.  
  917.    int i = 0, key;
  918.  
  919.    while (1) {
  920.        key = host_input(echo_asterisk);
  921.        if (!key) {                // timeout or user disconnect
  922.            setchr(buf, 0, 0);      // set string to empty
  923.            return 0;               // indicate there is a problem
  924.        }
  925.  
  926.        if (key == '^M')
  927.            break;
  928.        if (key == 127 || key == 8) {
  929.            if (i) {
  930.                --i;
  931.                host_send_c(key);
  932.            }
  933.            continue;
  934.        }
  935.        if (i < maximum) {
  936.            setchr(buf, i, key);
  937.            i = i + 1;
  938.        }
  939.        else
  940.            i = i + 1;
  941.    }
  942.  
  943.    if (i > maximum)
  944.        i = maximum;
  945.  
  946.    setchr(buf, i, '^0');
  947.  
  948.    if (subchr(buf, 0))
  949.        return 1;
  950.    else
  951.        return 0;
  952.  
  953. }
  954.  
  955. //////////////////////////////////////////////////////////////////////////////
  956.  
  957. host_input(int echo_asterisk) {
  958.  
  959. // Rev 11/25 88 by Jon Fleming to echo asterisk if "echo_asterisk" is
  960. //     non-zero, to echo the input character if "echo_asterisk" is zero.
  961.  
  962.    int c, t;
  963.  
  964.    t = timer_start(2400);         // 4 minutes inactivity allowed
  965.  
  966.    while (1) {
  967.        if (time_up(t) && !direct_connect) {
  968.            host_send("^M^J^M^JInactivity period too long. Connection terminated!^M^J");
  969.            ustamp("User terminated 4 min. inactivity.", 1, 1);
  970.            delay(10);
  971.            if (we_care_about_carrier)
  972.                hangup();
  973.            finished_caller = 1;
  974.            kill_user = 1;
  975.            return 0;
  976.        }
  977.  
  978.        if (we_care_about_carrier)
  979.            if (!carrier()) {
  980.                prints("^M^JConnection has been lost, call terminated.^M^J");
  981.                connection_lost = 1;
  982.                finished_caller = 1;
  983.            return 0;
  984.            }
  985.  
  986.        if ((c = inkey()) != 0) {
  987.             if (c == 0x3f00) {           // F5 key, sysop wants to exit to Telix.
  988.                host_send("^M^J* SysOp Terminated Session *^M^J");
  989.                ustamp("SysOp terminated host session.", 1, 1);
  990.                finished_caller = 1;
  991.                exit_requested = 1;
  992.                return 0;
  993.            }
  994.            else if (c == 0x3e00) {     // F4   Hang up on user
  995.                ustamp("User terminated!", 1, 1);
  996.                host_send("User terminated!^M^J");
  997.                delay(10);
  998.                if (we_care_about_carrier)
  999.                hangup();
  1000.  
  1001.                finished_caller = 1;
  1002.                kill_user = 1;
  1003.                return 0;
  1004.            }
  1005.            else if (c == 0x3b00)  {             // F1 Chat w/User
  1006.               host_send("^M^J^M^JSysOp breaking in for chat! ");
  1007.               ustamp("SysOp broke in, for chat w/user.", 1, 1);
  1008.               delay(20);
  1009.               chatmode();
  1010.               return 0;
  1011.            }
  1012.            else if (c == 0x3c00)  { // F2  Edit message.
  1013.               dos("q message.lst",1);
  1014.               return 0;
  1015.            }
  1016.            else if (c == 0x4000) {   // F6 Editor
  1017.               dos("nc.exe",1);
  1018.               return 0;
  1019.            }
  1020.            else if (c == 0x3d00)  {      /// F3 SysOp using Dos functions
  1021.               host_send("^M^J^M^J* Please Wait, SysOp is using DOS functions *");
  1022.               ustamp("SysOp used DOS functions.", 1, 1);
  1023.               dosfunction();
  1024.               host_send("^M^J^M^J* Thanks for waiting *^M^J^M^J");
  1025.               delay(10);
  1026.               return 0;
  1027.            }
  1028.  
  1029.            else if (c <= 255) {
  1030.                if (c != 8 && c != 127) {
  1031.                    if ( (echo_asterisk) && (c != 13) ) {
  1032.                    host_send_c ('*');
  1033.                    }
  1034.                    else {
  1035.                        host_send_c(c);
  1036.                    }
  1037.                }
  1038.                return c;
  1039.            }
  1040.        }
  1041.  
  1042.        if (!local_mode)
  1043.            if (cinp_cnt()) {
  1044.                c = cgetc();
  1045.                if (c != 8 && c != 127) {
  1046.                    if ( (echo_asterisk) && (c !=13) ) {
  1047.                    host_send_c ('*');
  1048.                    }
  1049.                else {
  1050.                    host_send_c(c);
  1051.                }
  1052.            }
  1053.            return c;
  1054.        }
  1055.    }
  1056. }
  1057.  
  1058. //////////////////////////////////////////////////////////////////////////////
  1059.  
  1060.  
  1061. // This routine maintains an ASCII file in the Telix files directory called
  1062. //     PASSWORD.TLX.  The format for each line is:
  1063.  
  1064. //     name;password;access_level  (optional comment)
  1065.  
  1066. //     The name, password, and acces_level fields MUST be seperated by
  1067. //     semicolons
  1068.  
  1069. // The routine searches the file for a line on which the "name" field
  1070. //     matches the global variable "current_caller"  (not case sensitive).
  1071.  
  1072. // If a match is found, and the user can type a password that matches
  1073. //     the "password" field (not case sensitive), the routine returns
  1074. //     the integer "access_level".
  1075.  
  1076. // If no match is found, the user is given an opportunity to reigister
  1077. //     (at access level 1).
  1078.  
  1079. // If the user registers, the file is updated with the new user name,
  1080. //     password, and access level (1), the routine returns 1.
  1081.  
  1082. // If the user does not register, or if the user cannot match the password
  1083. //     in the file in "maxtries",  or if the user registers and cannot match
  1084. //     the password he/she chose in "maxtries", the routine retuns 0.
  1085.  
  1086. ask_for_pass(int maxtries) {
  1087.    str password_file[64], line_from_file[80], address_from_file[20],
  1088.           citystate_from_file[20], zipcode_from_file[5],
  1089.           voicephone_from_file[14], modemphone_from_file[14],
  1090.           password_from_file[16], name_from_file[31], temporary[16],
  1091.           typed_password[16];
  1092.    int password_file_handle, field_length, field_start,
  1093.            found_password = 0, access_from_file, counter = 0,
  1094.            file_ends_in_control_z = 0, line_number = 0;
  1095.  
  1096.                                            // Build password file name
  1097.    password_file = _telix_dir;
  1098.    strcat (password_file, "PASSWORD.TLX");
  1099.                                            // Try to open password file
  1100.    if (password_file_handle = fopen (password_file, "r")) {
  1101.                                            // Read next line from file.
  1102.        while (fgets (line_from_file, 64, password_file_handle) != -1) {
  1103.                                            // Check for ^Z termination
  1104.            if (line_from_file == "^Z") {
  1105.                file_ends_in_control_z = 1;
  1106.                break;
  1107.            }
  1108.            line_number = line_number + 1;
  1109.                                            // If line is long enough . . .
  1110.            if (strlen (line_from_file) >= min_user_name+4) {
  1111.                                            // Get length of name
  1112.                if ( (field_length = strchr (line_from_file, 0, ';')) > 0) {
  1113.                                            // Get name
  1114.                    substr (line_from_file, 0, field_length, name_from_file);
  1115.                                            // If name matches . . . .
  1116.                    if (strcmpi (name_from_file, current_caller) == 0) {
  1117.                                            // Get password
  1118.                        field_start = field_length + 1;
  1119.                        if ( (field_length = strchr (line_from_file, field_start, ';') - field_start) > 0) {
  1120.                            substr (line_from_file, field_start, field_length, password_from_file);
  1121.                                            // Get access level
  1122.                            field_start = field_start + field_length + 1;
  1123.                            substr (line_from_file, field_start, 1, temporary);
  1124.                            access_from_file = stoi (temporary);
  1125.                                            // Set flag that we got an old user
  1126.                            found_password = 1;
  1127.                            break;
  1128.                        }
  1129.                        else {
  1130.                            password_file_error (line_number, line_from_file, "no second semicolon");
  1131.                        }
  1132.                    }
  1133.                }
  1134.                else {
  1135.                    password_file_error (line_number, line_from_file, "no first semicolon");
  1136.                }
  1137.            }
  1138.            else {
  1139.                password_file_error (line_number, line_from_file, "line too short");
  1140.            }
  1141.        }
  1142.        fclose (password_file_handle);
  1143.    }
  1144.  
  1145.    if (found_password) {
  1146.                                            // Password is on file; ask for it
  1147.        host_send ("Password...asterisks will echo: ");
  1148.        for (counter = 1; counter <= maxtries; counter = counter + 1) {
  1149.            host_input_strn (typed_password, 16, 1);
  1150.                                            // If a match
  1151.            if (strcmpi (typed_password, password_from_file) == 0) {
  1152.                host_send ("^M^J");
  1153.                return (access_from_file);
  1154.            }
  1155.            if (counter <maxtries) {
  1156.                host_send ("^M^JDoes not match password on file!  Please try again: ");
  1157.            }
  1158.            else {
  1159.                host_send ("^M^JMaximum number of tries exceeded!^M^J");
  1160.            }
  1161.        }
  1162.    }
  1163.                                            // Password is not on file
  1164.    else {
  1165.                                            // Offer chance to register
  1166.        host_send ("No user  ^"");
  1167.        host_send (current_caller);
  1168.        host_send ("^"  found in user file.^M^JDo you want to register? (Y/N): ");
  1169.        host_input_strn (temporary, 1, 0);
  1170.        host_send ("^M^J");
  1171.                                            // If user doesn't want to register
  1172.        if (not ((temporary == "Y") || (temporary == "y"))) {
  1173.            return (0);
  1174.        }
  1175.        while (1) {
  1176.                host_send ("^M^J");
  1177.                host_send ("^M^J");
  1178.        host_send ("What is your address ?(20 characters max.): ");
  1179.        host_input_strn (address_from_file, 20, 0);
  1180.        host_send ("^M^J");
  1181.        host_send ("^"");
  1182.        host_send (address_from_file);
  1183.        host_send ("^", correct? (y/N): ");
  1184.        host_input_strn (temporary, 20, 0);
  1185.        host_send ("^M^J");
  1186.                if (strcmpi (temporary, "y") == 0)
  1187.                break; }
  1188.  
  1189.        while (1) {
  1190.                host_send ("^M^J");
  1191.                host_send ("^M^J");
  1192.        host_send("What is your City & State ?(20 characters max.): ");
  1193.        host_input_strn (citystate_from_file, 20, 0);
  1194.        host_send ("^M^J");
  1195.        host_send ("^"");
  1196.        host_send (citystate_from_file);
  1197.        host_send ("^", correct? (y/N): ");
  1198.        host_input_strn (temporary, 20, 0);
  1199.        host_send ("^M^J");
  1200.                if (strcmpi (temporary, "y") == 0)
  1201.                break; }
  1202.  
  1203.        while (1) {
  1204.                host_send ("^M^J");
  1205.                host_send ("^M^J");
  1206.        host_send ("What is your Zip Code ?(5 characters max.): ");
  1207.        host_input_strn (zipcode_from_file, 5, 0);
  1208.        host_send ("^M^J");
  1209.        host_send ("^"");
  1210.        host_send (zipcode_from_file);
  1211.        host_send ("^", correct? (y/N): ");
  1212.        host_input_strn (temporary, 5, 0);
  1213.        host_send ("^M^J");
  1214.                if (strcmpi (temporary, "y") == 0)
  1215.                break; }
  1216.  
  1217.        while (1) {
  1218.                host_send ("^M^J");
  1219.                host_send ("^M^J");
  1220.        host_send ("What is your voice phone no. (example 214-283-3265): ");
  1221.        host_input_strn (voicephone_from_file, 14, 0);
  1222.        host_send ("^M^J");
  1223.        host_send ("^"");
  1224.        host_send (voicephone_from_file);
  1225.        host_send ("^", correct? (y/N): ");
  1226.        host_input_strn (temporary, 14, 0);
  1227.        host_send ("^M^J");
  1228.                if (strcmpi (temporary, "y") == 0)
  1229.                break; }
  1230.  
  1231.        while (1) {
  1232.                host_send ("^M^J");
  1233.                host_send ("^M^J");
  1234.        host_send ("What is your modem phone no. (example 214-283-3265): ");
  1235.        host_input_strn (modemphone_from_file, 14, 0);
  1236.        host_send ("^M^J");
  1237.        host_send ("^"");
  1238.        host_send (modemphone_from_file);
  1239.        host_send ("^", correct? (y/N): ");
  1240.        host_input_strn (temporary, 14, 0);
  1241.        host_send ("^M^J");
  1242.                if (strcmpi (temporary, "y") == 0)
  1243.                break; }
  1244.        
  1245.                host_send ("^M^J");
  1246.                host_send ("^M^J");
  1247.        host_send ("Pick a password (16 characters max.): ");
  1248.        host_input_strn (password_from_file, 16, 1);
  1249.                                            // Make sure password is right
  1250.        host_send ("^M^JRe-enter your password to verify: ");
  1251.        for (counter = 1; counter <= maxtries; counter = counter + 1) {
  1252.            host_input_strn (typed_password, 16, 1);
  1253.                                            // If all is ok
  1254.            if (strcmpi (typed_password, password_from_file) == 0) {
  1255.                                            // Build new line for password file
  1256.                line_from_file = current_caller;
  1257.                strcat (line_from_file, ";");
  1258.                strcat (line_from_file, password_from_file);
  1259.                strcat (line_from_file, ";1 ** NEW USER ** ");
  1260.                date (curtime(), temporary);
  1261.                strcat (line_from_file, temporary);
  1262.                                            // Open password file for appending
  1263.                password_file_handle = fopen (password_file, "a+");
  1264.                if (file_ends_in_control_z) {
  1265.                    fseek (password_file_handle, -1, 2);
  1266.                }
  1267.                                            // Now we can write the line
  1268.                fwrite (line_from_file, strlen (line_from_file), password_file_handle);
  1269.                fwrite ("^M^J", 2, password_file_handle);
  1270.                fclose (password_file_handle);
  1271.                host_send ("^M^J");
  1272.                                            // Return access level
  1273.                f = fopen("USER.INF", "a+"); 
  1274.                    fputs("^M^J", f);
  1275.                    fputs("Registered: ", f);
  1276.                    date(curtime(), s);
  1277.                    fputs(s, f);
  1278.                    fputs("^M^J", f);
  1279.                    fputs("User name: ", f);
  1280.                    fputs(current_caller, f);
  1281.                    fputs("^M^J", f);
  1282.                    fputs("Address: ", f);
  1283.                    fputs(address_from_file, f);
  1284.                    fputs("^M^J", f);
  1285.                    fputs("Location: ", f);
  1286.                    fputs(citystate_from_file, f);
  1287.                    fputs(" ", f);
  1288.                    fputs(zipcode_from_file, f);
  1289.                    fputs("^M^J", f);
  1290.                    fputs("Voice Phone: ",f);
  1291.                    fputs(voicephone_from_file, f);
  1292.                    fputs("^M^J", f);
  1293.                    fputs("Modem Phone: ",f);
  1294.                    fputs(modemphone_from_file, f);
  1295.                    fputs("^M^J", f);
  1296.                    fputs("Password: ", f);
  1297.                    fputs(password_from_file, f);
  1298.                    fputs("^M^J", f);
  1299.                    fclose(f);
  1300.                    host_send("^M^J");
  1301.                    host_send("Regristration Information Saved.....^M^J");
  1302.                    ustamp("User Registered.", 1, 1);
  1303.  
  1304.                    return (1);
  1305.  
  1306.            }
  1307.            if (counter < maxtries){
  1308.                host_send ("^M^JDoes not match!  Please try again: ");
  1309.            }
  1310.            else {
  1311.                host_send ("^M^JMaximum number of tries exceeded!^M^J");
  1312.            }
  1313.        }
  1314.    }
  1315.    return (0);
  1316. }
  1317.  
  1318. //////////////////////////////////////////////////////////////////////////////
  1319. // A routine to print an error message to the local screen when something
  1320. //     is wrong with the password file
  1321.  
  1322. password_file_error (int line_number, str line, str error_specifier) {
  1323.  
  1324.    str line_number_string[4];
  1325.  
  1326.    itos (line_number, line_number_string);
  1327.  
  1328.    prints ("");
  1329.    printsc ("Bad line ");
  1330.    printsc (line_number_string);
  1331.    prints (" in password file:");
  1332.    printsc ("   ^"");
  1333.    printsc (line);
  1334.    prints ("^"");
  1335.    prints (error_specifier);
  1336.  
  1337.    return (1);
  1338. }
  1339.  
  1340. //////////////////////////////////////////////////////////////////////////////
  1341.  
  1342. //Rev 11/25/88 by Jon Fleming to not read the lines from the old host mode
  1343. //  configuration file that are no longer applcable.
  1344.  
  1345. read_host_config_file() {
  1346.  
  1347.    str config_file_name[80], buffer [32];
  1348.    int config_file_handle;
  1349.  
  1350.    config_file_name = _telix_dir;
  1351.    strcat(config_file_name, "NHOST.CNF");
  1352.  
  1353.    
  1354.    if (not (config_file_handle = fopen(config_file_name, "r"))) {
  1355.        printsc("Can't open ");
  1356.        prints(config_file_name);
  1357.        return -1;
  1358.    }
  1359.  
  1360.    if (fgets(host_downloads, 80, config_file_handle) == -1) {
  1361.        fclose(config_file_handle);
  1362.        return -1;
  1363.    }
  1364.  
  1365.    if (fgets(host_uploads, 80, config_file_handle) == -1) {
  1366.        fclose(config_file_handle);
  1367.        return -1;
  1368.    }
  1369.  
  1370.    if (fgets(buffer, 80, config_file_handle) == -1) {
  1371.        fclose(config_file_handle);
  1372.        return -1;
  1373.    }
  1374.    direct_connect = (toupper(subchr(buffer, 0)) == 'D');
  1375.  
  1376.    fclose(config_file_handle);
  1377.    return 1;
  1378.  
  1379. }
  1380.  
  1381. //////////////////////////////////////////////////////////////////////////////
  1382.  
  1383. check_directories() {
  1384.  
  1385.    str s[80];
  1386.    int i, a;
  1387.  
  1388.    // first remove trailing slashes
  1389.  
  1390.    s = host_uploads;
  1391.    i = strlen(s);
  1392.    if (i > 0)
  1393.        if (subchr(s, i - 1) == '\' || subchr(s, i - 1) == '/')
  1394.            setchr(s, i - 1, 0);
  1395.    if (s && !(strlen(s) == 2 && subchr(s, 1) == ':')) {
  1396.        a = fileattr(s);
  1397.        if (a == -1 || !(a & 16))
  1398.            return 0;                  // not a directory or doesn't exist
  1399.    }
  1400.  
  1401.    s = host_downloads;
  1402.    i = strlen(s);
  1403.    if (i > 0)
  1404.        if (subchr(s, i - 1) == '\' || subchr(s, i - 1) == '/')
  1405.            setchr(s, i - 1, 0);
  1406.    if (s && !(strlen(s) == 2 && subchr(s, 1) == ':')) {
  1407.        a = fileattr(s);
  1408.        if (a == -1 || !(a & 16))
  1409.            return 0;                  // not a directory or doesn't exist
  1410.    }
  1411.  
  1412.    return 1;
  1413.  
  1414. }
  1415.  
  1416. //////////////////////////////////////////////////////////////////////////////
  1417. // returns TRUE if passed filespec is just a filename. Also handles the
  1418. // forward slash as a path separator.
  1419.  
  1420. just_filename(str filespec) {
  1421.  
  1422.    int slash, space;
  1423.  
  1424.    if (strpos(filespec, ":", 0) != -1)
  1425.        return 0;
  1426.    if (strpos(filespec, "\", 0) != -1)
  1427.        return 0;
  1428.    if ((slash = strpos(filespec, "/")) == -1)
  1429.        return 1;
  1430.  
  1431.    space = strpos(filespec, " ");
  1432.    if (space == -1)
  1433.        return 0;
  1434.    if (space < slash)
  1435.        return 1;
  1436.  
  1437.    return 0;
  1438.  
  1439. }
  1440.  
  1441. //////////////////////////////////////////////////////////////////////////////
  1442.